import { NgModule, APP_INITIALIZER } from '@angular/core';
import { DatePipe } from "@angular/common";
import { ReactiveFormsModule } from '@angular/forms';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { DefaultModule } from '@global/layout';
import { MessageService, WebsocketService, SharedModule, CommonService } from '@global/shared';
import { HttpErrorHandler } from '@global/shared/http-error-handler.service';
import { RouteguardService } from '@global/shared/routeGuard.service';
import { TranslateModule } from '@ngx-translate/core';

import { KeycloakModule } from 'keycloak-iop';
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { NgZorroIopModule, CookiesService } from 'ng-zorro-iop';

import { AppRoutingModule } from './app-routing.module';

import { AppComponent } from './app.component';
import { AppConfig, initializer } from './app-init';
import { OverviewComponent } from './overview/overview.component';
import { MonacoEditorModule } from "ngx-monaco-editor";
import { registerLocaleData } from '@angular/common';
import zh from '@angular/common/locales/zh';
import { FcsNotOpenedComponent } from './fcs-not-opened/fcs-not-opened.component';
import { FcsSuspendedComponent } from './fcs-suspended/fcs-suspended.component';
import { FcsStatusService } from "./service/fcs-status.service";
import { FcsServiceStartupService } from "./service/fcs-service-startup.service";
import { DomainListComponent } from './domain/list/domain-list.component';
import { DomainCreateComponent } from './domain/create/domain-create.component';

registerLocaleData(zh);
@NgModule({
  imports: [
    NoopAnimationsModule,
    DefaultModule,
    NgZorroIopModule,
    NgZorroAntdModule,
    TranslateModule.forRoot(),
    AppRoutingModule,
    KeycloakModule,
    ReactiveFormsModule,
    SharedModule,
    MonacoEditorModule.forRoot(),
  ],
  declarations: [
    AppComponent,
    OverviewComponent,
    FcsNotOpenedComponent,
    FcsSuspendedComponent,
    DomainListComponent,
    DomainCreateComponent,
  ],
  providers: [
    CookiesService,
    CommonService,
    AppConfig,
    {
      provide: APP_INITIALIZER,
      useFactory: initializer,
      deps: [AppConfig, CommonService],
      multi: true,
    },
    HttpErrorHandler,
    RouteguardService,
    MessageService, WebsocketService,
    FcsStatusService,
    FcsServiceStartupService,
    DatePipe
  ],
  entryComponents: [
    DomainCreateComponent,
  ],
  bootstrap: [AppComponent]
})

export class AppModule {
}
